<?php
namespace catchAdmin\propaganda\controller;

use catcher\CatchResponse;
use catcher\base\CatchRequest;
use catcher\base\CatchController;

use app\common\model\PropagandaEducationClass as PropagandaEducationClassModel;

class Educationclass extends CatchController
{
  protected $propagandaEducationClass;

  public function __construct(PropagandaEducationClassModel $propagandaEducationClass)
  {
      $this->propagandaEducationClass = $propagandaEducationClass;
  }

  /**
   * 列表
   *
   * @time 2020年01月09日
   * @param CatchRequest $request
   * @return \think\response\Json
   * @throws \think\db\exception\DbException
   */
  public function index(): \think\response\Json
  {
      return CatchResponse::paginate($this->propagandaEducationClass->getList());
  }

  /**
   * 保存
   *
   * @time 2020年01月09日
   * @param CatchRequest $request
   * @return \think\response\Json
   */
  public function save(CatchRequest $request): \think\response\Json
  {
      return CatchResponse::success($this->propagandaEducationClass->addData($request->param()));
  }

  /**
   * 更新
   *
   * @time 2020年01月09日
   * @param $id
   * @param CatchRequest $request
   * @return \think\response\Json
   */
  public function update($id, CatchRequest $request): \think\response\Json
  {
      return CatchResponse::success($this->propagandaEducationClass->saveData($id, $request->param()));
  }

  /**
   * 删除
   *
   * @time 2020年01月09日
   * @param $id
   * @return \think\response\Json
   */
  public function delete($id): \think\response\Json
  {
      return CatchResponse::success($this->propagandaEducationClass->destroy($id));
  }    

  /**
   * 获取宣教分类数据
   * @return \think\response\Json
   */
  public function get_educationclass()
  {
      return CatchResponse::success($this->propagandaEducationClass->getDatas());
  }
}